package main

import (
	"github.com/gin-gonic/gin"
	"hitme/go-api/logic/middlewares"
	"hitme/go-api/modules/engine"
	"hitme/go-api/routers/api"
)

var eng *engine.Engine

func main()  {
	//gin.SetMode(gin.ReleaseMode)
	//gin.DefaultWriter = ioutil.Discard

	r := gin.Default()

	eng = engine.Default().AddConfigFromYAML("./config.yml")

	// 设置跨域中间件
	r.Use(middlewares.Cors())

	// 全局异常捕获
	r.Use(middlewares.GinLogger(), middlewares.GinRecovery(true))

	// 首页
	r.GET("/", func(c *gin.Context) {
		c.Header("Content-Type", "text/html; charset=utf-8")
		c.String(200, `<b>Hello go photo</b>`)
	})

	// 添加路由
	apiV1Router := r.Group("/api/v1/")
	api.ApiV1Router(apiV1Router)

	_ = r.Run(":8098")
}